package com.lmf.controller;

import com.lmf.entity.Article;
import com.lmf.mapper.UserMapper;
import com.lmf.service.UserService;
import com.lmf.tool.CustomException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {
    private static Logger logger= LoggerFactory.getLogger(UserController.class);
    @Autowired
    UserService userService;
    @Autowired
    UserMapper userMapper;

/*    @GetMapping("/getUser")
    public String getUser(User user){
        logger.info("request paramter {} {}",user.getName(),user.getId());
       User u= userService.getUserById(user);
       if(u==null){
           CustomException customException=  new CustomException(404,"找不到用户信息");
           return customException.getMessage();
       }else {
           return u.getName();
       }
    }*/
    @GetMapping("/test")
    public String test(){
        List<Article> list=userMapper.selectList(null);
        if(list.isEmpty()){
            CustomException customException=  new CustomException(404,"找不到用户信息");
            return customException.getMessage();
        }else{
            list.forEach(System.out::println);
            return "test";
        }
    }
}
